package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.CommonIdVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.MemberStoreAddVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.MemberStorePageVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.MemberStoreUpdateVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberStoreDetailVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberStorePageQueryVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberAbilityStoreService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 系统能力 - 权限管理 - 门店管理
 * @author wyx
 * @version 2.0.0
 * @date 2022/02/10
 */
@RestController
@RequestMapping("/member/store")
public class MemberAbilityStoreController {

    @Resource
    private IMemberAbilityStoreService memberAbilityStoreService;


    /**
     * 门店管理分页查询列表
     * @param headers HttpHeaders信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberStorePageQueryVO>> memberStorePages(@RequestHeader HttpHeaders headers, @Valid MemberStorePageVO pageVO) {
        return memberAbilityStoreService.memberStorePages(headers, pageVO);
    }

    /**
     * 查看门店详情
     * @param headers HttpHeaders信息
     * @param idVO    接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<MemberStoreDetailVO> memberStoreDetail(@RequestHeader HttpHeaders headers, @Valid CommonIdVO idVO) {
        return memberAbilityStoreService.memberStoreDetail(headers, idVO);
    }

    /**
     * 新增门店
     * @param headers HttpHeaders信息
     * @param addVO   接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> addMemberStore(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberStoreAddVO addVO) {
        return memberAbilityStoreService.addMemberStore(headers, addVO);
    }

    /**
     * 修改门店
     * @param headers  HttpHeaders信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberStore(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberStoreUpdateVO updateVO) {
        return memberAbilityStoreService.updateMemberStore(headers, updateVO);
    }

    /**
     * 删除门店
     * @param headers HttpHeaders信息
     * @param idVO    接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteMemberStore(@RequestHeader HttpHeaders headers, @RequestBody @Valid CommonIdVO idVO) {
        return memberAbilityStoreService.deleteMemberStore(headers, idVO);
    }

    /**
     * 启用/停用门店
     * @param headers HttpHeaders信息
     * @param idVO    接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/enable", method = RequestMethod.POST)
    public Wrapper<Void> enableMemberStore(@RequestHeader HttpHeaders headers, @RequestBody @Valid CommonIdVO idVO) {
        return memberAbilityStoreService.enableMemberStore(headers, idVO);
    }
}
